/*
 * Copyright (C) Michael Opitz
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA
 */
#ifndef DATA_MINER_H
#define DATA_MINER_H

#include "apriori/apriori.h"
#include "../model/client.h"
#include "../model/title.h"

#include "title_dataset.h"
#include "title_adapter.h"
#include "file_streamer.h"
#include "../model/model_class.h"

#include <boost/shared_ptr.hpp>

#include <list>
#include <iostream>

using namespace std;

/** 
 * \brief This namespace includes all music-related stuff.
 * \author Michael Opitz
 */
namespace music {
	/** 
	 * \brief this class provides a facade for the apriori-algorithm.
	 */
	class data_miner {
	public:
		typedef apriori::apriori_alg<music::title_dataset, list> 
			my_apriori;
		typedef my_apriori::t_itemset_c::data_ptr data_ptr;

		/** 
		 * \brief data_miner creates the object.
		 * 
		 * \param clt is a shared_ptr to the client which datas should
		 * be used for the algorithm.
		 * \param m is a shared_ptr to the main-model-class.
		 */
		data_miner(boost::shared_ptr<model::client> clt,
			boost::shared_ptr<model::model_class> m)
		:_client(clt), _model(m){}
		~data_miner() {}

		/** 
		 * \brief doit executes the apriori-algorithm.
		 */
		void doit();
		/** 
		 * \brief get_result returns the result of the algorithm.
		 * 
		 * \return a shared_ptr to a title is returned. If the algorithm
		 * wasn't successfull an empty pointer is returned.
		 */
		boost::shared_ptr<model::title> get_result() { return _result; }
	private:
		list<boost::shared_ptr<music::title_adapter> > create_list(
			const list<string> &l);
		list<boost::shared_ptr<music::title_dataset> > 
			create_datasets(const list<boost::shared_ptr<
						music::title_adapter> > &l);

		boost::shared_ptr<model::client> _client;
		boost::shared_ptr<model::title> _result;
		boost::shared_ptr<model::model_class> _model;
	};
}

#endif

